﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HanGu.Services.Interface;
using HanGu.Entity;

namespace HanGu.Services
{
    public class AreaService : BaseService,IArea
    {
        public List<Area> GetProvices()
        {
            using (HaiGuEntities obj = new HaiGuEntities())
            {
                return obj.Area.Where(c => c.AreaCode.Length == 2).OrderBy(c => c.AreaName).ToList();
            }
        }
        public List<Area> GetCitys()
        {
            using (HaiGuEntities obj = new HaiGuEntities())
            {
                return obj.Area.Where(c => c.Root == true).OrderBy(c=>c.AreaCode).ThenBy(c => c.AreaName).ToList();
            }
        }
        public List<Area> GetCitys(string ParentAreaCode) 
        {
            using (HaiGuEntities obj = new HaiGuEntities())
            {
                return obj.Area.Where(c => c.ParentAreaCode == ParentAreaCode).OrderBy(c => c.AreaName).ToList();
            }
        }
    }
}
